package com.wzdigit.wms.common.utils;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;




/**
 * Oracle解决IN超过1000工具类
 * Created by zyf on 2021/8/30 10:57
 */
public class QueryInUtil {

    /**
     * 解决Oracle中in的参数列表长度超过1000的问题
     *
     * @param length
     *            每个分段的长度，
     * @param paramsList
     *            待拆分的参数列表
     * @return 拆分后的分段列表
     */
    public static <T> List<List<T>> splitInParams(int length, List<T> paramsList) {
        if (length<1||paramsList == null || paramsList.size() == 0)
            return null;
        int size = paramsList.size();
        List<List<T>> list = new ArrayList<List<T>>();
        int d = (int) Math.ceil(size / (length+0.0));
        for (int i = 0; i < d; i++) {
            int fromIndex = length * i;
            int toIndex = Math.min(fromIndex + length, size);
            list.add(paramsList.subList(fromIndex, toIndex));
        }
        return list;
    }

}
